#!/usr/bin/env python
# -*- coding:utf-8 -*-
"""
@author:余振新
@file: path.py
@time: 2023/04/07
"""

import os
from typing import Text


# 用于将相对路径转换为绝对路径


def root_path():
    """ 获取 根路径 """
    path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    return path


def ensure_path_sep(path: Text) -> Text:
    """兼容 windows 和 linux 不同环境的操作系统路径 """
    if "/" in path:
        path = os.sep.join(path.split("/"))
    if "\\" in path:
        path = os.sep.join(path.split("\\"))
    return root_path() + path


if __name__ == "__main__":
    a = ensure_path_sep("/browserdriver/chrome_driver/chromedriver.exe")
    print(a)
